Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Drawing
Imports System.Data
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports System.IO
Imports C4F.DevKit.WebServices.Datasets
Imports C4F.DevKit.WebServices


Namespace C4F.DevKit.WebServicesDemo
	Public Partial Class FlickrControl
		Inherits UserControl
		Public Sub New()
			InitializeComponent()
		End Sub

		Private Sub SearchFlickr_Click(ByVal sender As Object, ByVal e As EventArgs) Handles SearchFlickr.Click
            Try
                FlickrService.ApplicationKey = AppKey.Text
                FlickrResults = FlickrService.SearchByUserId_DS(SearchTerm.Text)
                FlickrGrid.DataSource = FlickrResults.PhotoData
            Catch ex As System.Net.WebException
                Dim streamReader As StreamReader = New StreamReader(ex.Response.GetResponseStream())
                Dim responseData As String = streamReader.ReadToEnd()
                streamReader.Close()
                MessageBox.Show(responseData)
            Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
        End Sub

		Private Sub FlickrGrid_CellContentClick(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles FlickrGrid.CellContentClick
			Dim Cells As DataGridViewSelectedCellCollection = FlickrGrid.SelectedCells
			If TypeOf Cells(0) Is System.Windows.Forms.DataGridViewLinkCell Then
				Dim LinkCell As DataGridViewLinkCell = CType(Cells(0), DataGridViewLinkCell)
				Dim BrowserForm As DemoBrowser = New DemoBrowser(CStr(LinkCell.Value))
				BrowserForm.Show()
			End If
		End Sub
	End Class
End Namespace
